//
//  MJVideo.m
//  MJVideoPlayer
//
//  Created by 梅杰 on 16/8/13.
//  Copyright © 2016年 梅杰. All rights reserved.
//

#import "MJVideo.h"
#import "UIImage+MJPlayer.h"
@interface MJVideo () <NSCoding>

@end

@implementation MJVideo

- (void)setUrl:(NSURL *)url{
    _url = url;
    _imageUrlString = [UIImage localUrlWithImageWithVideoUrl:url];
}

- (void)setName:(NSString *)name{
    _name = name;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.imageUrlString forKey:@"KImageUrl"];
    [aCoder encodeObject:self.name forKey:@"KName"];
    [aCoder encodeObject:self.url forKey:@"KUrl"];
    [aCoder encodeObject:self.author forKey:@"KAuthor"];
    [aCoder encodeObject:self.length forKey:@"KLength"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
//    return nil;
    if (self = [super init]) {
        if (aDecoder == nil) {
            return self;
        }
        self.imageUrlString = [aDecoder decodeObjectForKey:@"KImageUrl"];
        self.name = [aDecoder decodeObjectForKey:@"KName"];
        self.url = [aDecoder decodeObjectForKey:@"KUrl"];
        self.author = [aDecoder decodeObjectForKey:@"KAuthor"];
        self.length = [aDecoder decodeObjectForKey:@"KLength"];
    }
    return self;
}

@end
